package com.example.rydwlib.adapter

import android.graphics.Color
import android.widget.TextView
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
import com.example.baselib.utils.TimeUtils
import com.example.rydwlib.R
import com.example.rydwlib.bean.Sysalarm

/**
 * Author: sxygsj
 * Date: 2020/5/7 9:57
 * Description: 系统异常适配器
 * History:
 * <author> <time> <version> <desc>
 * 作者姓名 修改时间 版本号 描述
 */
class RySysAlarmAdapter(layoutResId: Int):BaseQuickAdapter<Sysalarm,BaseViewHolder>(layoutResId) {
    override fun convert(helper: BaseViewHolder, item: Sysalarm) {
        val view = helper.getView<TextView>(R.id.ry_alarm_sys_endtime)
        val tp = view.paint
        var endtime: String?
        if (item.abnormalendtime== null) {
            tp.isFakeBoldText = true
            view.setTextColor(Color.parseColor("#FF0000"))
            endtime = "正在报警"
        } else {
            endtime = TimeUtils.timeFormat(item.abnormalendtime)
        }
        helper.setText(R.id.ry_alarm_sys_sname, item.staionname)
            .setText(R.id.ry_alarm_sys_scode, item.stationnum)
            .setText(
                R.id.ry_alarm_sys_starttime,
                TimeUtils.timeFormat(item.abnormalstarttime)
            ).setText(R.id.ry_alarm_sys_endtime, endtime)
            .setText(R.id.ry_alarm_sys_operamsg, item.operatetext)
            .setText(R.id.ry_alarm_sys_errmsg, item.abnormaltext)
    }
}